package retrofit.boot.exception;

import org.apache.commons.lang3.StringUtils;
import retrofit.client.Response;

/**
 * Created by wulg on 2019/10/21
 * description:RetrofitClient-Http异常
 */
public class RetrofitClientHttpException extends RetrofitClientException {

    private final Response response;

    public RetrofitClientHttpException(Response response, Throwable cause) {
        super(String.format("status code: %d" + (StringUtils.isBlank(response.getReason()) ? "" : ", reason: %s"), response.getStatus(), response.getReason()),cause);
        this.response = response;
    }

    public int getStatusCode() {
        return response.getStatus();
    }

    public String getReason() {
        return response.getReason();
    }

}
